package com.android.hedgehog.puzzles;

import java.util.List;

import android.graphics.Color;

import com.android.hedgehog.Assets;
import com.android.hedgehog.framework.Game;
import com.android.hedgehog.framework.Graphics;
import com.android.hedgehog.framework.Input.TouchEvent;
import com.android.hedgehog.puzzles.MathScreen.GameState;

public class SeesawScreen2 extends PuzzleScreen {
	public enum PuzzleState {
		Running, Finish
	}

	SeesawBoard2 board;
	PuzzleState state;
	Graphics graphics;
	int difficulty;

	public SeesawScreen2(Game game, int gameType, int difficulty, int instNumber) {
		this.graphics = game.getGraphics();
		this.gameType = gameType;
		this.instanceNumber = instNumber;
		this.difficulty = difficulty;
		state = PuzzleState.Running;
		board = new SeesawBoard2(difficulty);

	}

	@Override
	public void update(List<TouchEvent> touchEvents, double deltaTime) {
		int len = touchEvents.size();
		for (int i = 0; i < len; i++) {// FOR
			TouchEvent event = touchEvents.get(i);
			if (event.type == TouchEvent.TOUCH_UP) {
				instanceOver = true;
			}
		}

	}

	@Override
	public void present() {
		if (state == PuzzleState.Running)
			presentRunning();
		if (state == PuzzleState.Finish)
			presentFinish();
	}

	private void presentRunning() {

		// background
		graphics.drawUniversalRect(0, 31, 320, 449, false, true, 1, 255, Color.WHITE);

		for (int i = 0; i < board.blocks.length; i++) {
			graphics.drawUniversalRect(board.blocks[i].xCoordinate, board.blocks[i].yCoordinate, 30, 30,
					false, true, 1, 255, board.blocks[i].color);
			graphics.drawUniversalRect(board.blocks[i].xCoordinate, board.blocks[i].yCoordinate, 30, 30,
					false, false, 3, 255, Color.BLACK);
			graphics.drawUniversalText("" + board.blocks[i].blockWeight, 2, true,
					board.blocks[i].xDigitCoordinate, board.blocks[i].yDigitCoordinate, 22, 255, Color.BLACK);
		}
		graphics.drawPixmap(Assets.board, 20, 190, 0, 0, 280, 60);
		//graphics.drawUniversalText("" + board.leftBoardTotalValue, 2, true, 40, 440, 32, 255, Color.BLUE);
		//graphics.drawUniversalText("" + board.rightBoardTotalValue, 2, true, 280, 440, 32, 255, Color.BLUE);
		graphics.drawUniversalText("Which way will the seesaw tilt?", 2, true, 160, 380, 16, 255, Color.BLACK);
		graphics.drawUniversalText(board.test, 2, true, 160, 410, 11, 255, Color.GRAY);
	}

	private void presentFinish() {

	}

}
